package top.lunarye.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/**
 * @author lunar
 * @since 2022-07-18
 */
@ToString
@Getter
@AllArgsConstructor
public enum MessageType {
    NOTICE(10, "通知类消息", "notice"),
    AUTH_CODE(20, "验证码消息", "auth_code")
    ;

    private final Integer code;

    private final String description;

    private final String codeEn;

    /**
     * 通过code获取enum
     * @param code
     * @return
     */
    public static MessageType getEnumByCode(Integer code) {
        MessageType[] values = values();
        for (MessageType value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}
